package com.kingsoft.demo.excel.poi;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;


/**
 * 生成Excel
 *
 */
public class ExcelTestB {

	public static void main(String[] args) {
		
		HSSFWorkbook workbook = new HSSFWorkbook();
		HSSFSheet sheet = workbook.createSheet();
		HSSFRow row;
		
		//填充数据
		for(int i =0 ;i<10;i++){
			row = sheet.createRow(i);
			row.createCell(0).setCellValue(i);
			row.createCell(1).setCellValue(i);
			row.createCell(2).setCellValue(i);
			row.createCell(3).setCellValue(i);
		}
		
		String filePath = "";
		try {
			FileOutputStream fos = new FileOutputStream(filePath);
			workbook.write(fos);
			fos.close();
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			System.out.println("写入失败");
			e.printStackTrace();
		}
		
		
		
	}
}
